<script setup lang='ts'>
import { onMounted, ref } from 'vue';
import { useHeaderStore } from '../../../store'
import type { Game } from '../../../store/index'

const store = useHeaderStore()
const data = ref<Game>({
    playbill: '',
    banner: [],
    newgame: []
})
onMounted(async () => {
    await store.getData()
    data.value = store.getGame
})
</script>
<template>
    <div class="game-box">
        <div class="game-left">
            <div class="playbill-box">
                <img :src="data.playbill" alt="">
            </div>
            <div class="banner-box">
                <div class="banner-item" v-for="item in data.banner" :key="item.name">
                    <img :src="item.img" alt="">
                    <div class="banner-name">{{item.name}}</div>
                </div>
            </div>
        </div>
        <div class="game-right">
            <div class="title">新游预告</div>
            <ul class="newgame-list">
                <li v-for="item in data.newgame" :key="item">{{item}}</li>
            </ul>
        </div>
    </div>
</template>
<style lang='less' scoped>
.game-box {
    display: flex;
    width: 384px;
    height: 255px;

    .game-left {
        display: flex;
        flex-direction: column;
        padding-right: 20px;
        border-right: 1px solid #ccc;
        box-sizing: border-box;
        width: 250px;

        .playbill-box {
            width: 230px;
            height: 129px;
            border-radius: 8px;
            overflow: hidden;
            flex-shrink: 0;

            img {
                width: 100%;
                height: 100%;
            }
        }

        .banner-box {
            display: flex;
            justify-content: space-between;
            margin-top: 16px;
            width: 100%;

            .banner-item {
                display: flex;
                flex-direction: column;
                width: 66px;

                img {
                    border-radius: 8px;
                    overflow: hidden;
                    width: 66px;
                    height: 66px;
                    flex-shrink: 0;
                }

                .banner-name {
                    margin-top: 10px;
                    width: 100%;
                    font-size: 13px;
                    line-height: 17px;
                    word-break: break-all;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    line-break: anywhere;
                    -webkit-line-clamp: 2;
                    flex-shrink: 0;
                }
            }
        }
    }

    .game-right {
        padding-left: 28px;

        .title {
            font-size: 20px;
            line-height: 28px;
            margin-bottom: 10px;
        }

        .newgame-list {
            li {
                overflow: hidded;
                white-space: nowrap;
                text-overflow: ellipsis;
                width: 120px;
                font-size: 13px;
                line-height: 29px;
                margin-bottom: 2px;
                color: var(--text2);
            }
        }
    }
}
</style>